$(function() {
	readygradeindex("addsubject-select");
    $("#submit").click(function() {
    	/**
         * 获取编号
         */
         var mydate= new Date(); //获取当前时间到毫秒
         var Code = mydate.getTime().toString().slice(5,11); //截取5-11位
         var oDate = new Date(); //实例一个时间对象；
         var year= oDate.getFullYear(); //获取系统的年；
         var morth=oDate.getMonth()+1; //获取系统月份，由于月份是从0开始计算，所以要加1
         var day=oDate.getDate(); // 获取系统日，
         var q = year+"."+morth+"."+day;
        
         /**
          * 获取数据
          */
        var subjectName = "《"+$("#subjectName").val()+"》";
        var subjectCode = Code;
        var gradeID = $("#addsubject-select option").val();
        var url="/blackhouse/subjectadd";
        var data={};//json
        data.subjectName=subjectName;
        data.subjectCode=subjectCode;
        data.gradeID=gradeID;
        $.ajax({
   		 	url: "/blackhouse/subjectadd",
   	        type: "post",
   	        data:data,
   	        dataType: "json",
   	        async:false,//同步
   	        success: function(e) {
   	         if(e[0].isok){
   	        	subjectadd(subjectCode,subjectName,e[0].iD,q,gradeID);
   	        }else{
   	        	alert("添加失败")
   	        	}
   	        }
   	 	})
       
    })
})
function subjectadd(subjectCode,subjectName,teacherName,q,gradeID){
	
	var strVar="";
	strVar += " <tr>";
	strVar += "<td>"+subjectCode+"<\/td>";
	strVar += "<td>"+subjectName+"<\/td>";
	strVar += "<td>"+teacherName+"<\/td>";
	strVar += "<td>"+q+"<\/td>";
	strVar += " <td>"+gradeID+"<\/td>";
	strVar += "<\/tr>";
	$("table tbody").html($("table tbody").html()+strVar);
}